<?php

namespace App\Http\Requests\Admin\Ca;

use App\Facade\AppContext;
use App\Http\Requests\BaseFormRequest;

class DockerSaveRequest extends BaseFormRequest
{
    protected function passedValidation()
    {
        $id = $this->get('id', 0);
        if (empty($id))
            $this->offsetSet('hospital_id', AppContext::hospitalId());
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => [
                'required',
                'between:2,50'
            ]
        ];
    }

    public function messages()
    {
        return [
            'name.required' => '请输入名称',
            'name.between' => '名称字符长度:min-:max'
        ];
    }
}